package com.hundsun.cprs.yyt.gateway.service.uc;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class BankBindingFactory implements ApplicationContextAware {
    
    private Map<String, BankBindingService> bankBindingServiceMap = new HashMap<String,BankBindingService>(4);

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //加载所有银行渠道处理器
        Map<String, BankBindingService> beanMap = applicationContext.getBeansOfType(BankBindingService.class);
        for(BankBindingService bean : beanMap.values()){
            bankBindingServiceMap.put(bean.getBankNo(), bean);
        }
    }
    
    public BankBindingService getBankBindingService(String bankNo){
        return bankBindingServiceMap.get(bankNo);
    }

}
